For this lesson we will start with a residual total magnetic intensity (TMI) data grid for the Wittichica Creek area of British Columbia, Canada. This data was downloaded from the Geoscience Data Portal of the Geoscience Canada using Geosoft Seeker.
The most common requirement for a grid is to present the grid data as a colour image that can be viewed or printed. In this exercise we will first view the grid, then add contours, shading and a colour legend, and finally we will add location annotations and complete the map ready for printing or sharing.
See also: Tutorial page
Some map features in this notebook require a Geosoft End-User License.
Geosoft maps are used to present geoscience information on a 2D surface, which can be a computer screen or printed on paper.
In [3]:
import geosoft.gxpy.gx as gx
import geosoft.gxpy.view as gxview
import geosoft.gxpy.group as gxgroup
import geosoft.gxpy.agg as gxagg
import geosoft.gxpy.grid as gxgrd
import geosoft.gxpy.viewer as gxviewer
import geosoft.gxpy.utility as gxu
import geosoft.gxpy.map as gxmap
from IPython.display import Image
gxc = gx.GXpy()
url = 'https://github.com/GeosoftInc/gxpy/raw/9.3.1/examples/data/'
gxu.url_retrieve(url + 'Wittichica Creek Residual Total Field.grd')
gxu.url_retrieve(url + 'Wittichica Creek Residual Total Field.grd.gi')
gxu.url_retrieve(url + 'Wittichica Creek Residual Total Field.grd.xml')
Out[3]:
In [4]:
import geosoft.gxpy.gx as gx
import geosoft.gxpy.map as gxmap
import geosoft.gxpy.view as gxview
import geosoft.gxpy.group as gxgroup
import geosoft.gxpy.agg as gxagg
import geosoft.gxpy.grid as gxgrd
import geosoft.gxpy.viewer as gxviewer
gxc = gx.GXpy()
# get the grid extent and coordinate system from which we will create a default map named after the grid
# do this in a separate `with...` as the Aggregate_group class needs access to the grid file.
with gxgrd.Grid('Wittichica Creek Residual Total Field.grd') as grid:
extent = grid.extent_2d()
coordinate_system = grid.coordinate_system
grid_file_name = grid.file_name
map_file_name = grid_file_name + '.map'
# create a map for this grid on A4 media, scale to fit the extent
with gxmap.Map.new(map_file_name,
data_area=extent,
media="A4",
margins=(1, 3.5, 3, 1),
coordinate_system=coordinate_system,
overwrite=True) as gmap:
# work with the data view
with gxview.View.open(gmap, "data") as v:
# add the grid image to the view
with gxagg.Aggregate_image.new(grid_file_name) as agg:
gxgroup.Aggregate_group.new(v, agg)
# display the map as an image
Image(gxmap.Map.open(map_file_name).image_file(pix_width=800))
Out[4]:
In [5]:
with gxmap.Map.new(map_file_name,
data_area=extent,
media="A4",
margins=(1, 3.5, 3, 1),
coordinate_system=coordinate_system,
overwrite=True) as gmap:
# work with the data view, draw a line around the data view
with gxview.View.open(gmap, "data") as v:
# add the grid image to the view, with shading, 20 nT contour interval to match default contour lines
with gxagg.Aggregate_image.new(grid_file_name, shade=True, contour=20) as agg:
gxgroup.Aggregate_group.new(v, agg)
# contour the grid
gxgroup.contour(v, 'TMI_contour', grid_file_name)
# display the map as an image
Image(gxmap.Map.open(map_file_name).image_file(pix_width=800))
Out[5]:
In [6]:
with gxmap.Map.new(map_file_name,
data_area=extent,
media="A4",
margins=(1, 3.5, 3, 1),
coordinate_system=coordinate_system,
overwrite=True) as gmap:
# work with the data view, draw a line around the data view
with gxview.View.open(gmap, "data") as v:
# add the grid image to the view, with shading, 20 nT contour interval to match default contour lines
with gxagg.Aggregate_image.new(grid_file_name, shade=True, contour=20) as agg:
gxgroup.Aggregate_group.new(v, agg)
# colour legend
gxgroup.legend_color_bar(v, 'TMI_legend',
title='Res TMI\nnT',
location=(1.2,0),
cmap=agg.layer_color_map(0),
cmap2=agg.layer_color_map(1))
# contour the grid
gxgroup.contour(v, 'TMI_contour', grid_file_name)
# map title and creator tag
with gxview.View.open(gmap, "base") as v:
with gxgroup.Draw(v, 'title') as g:
g.text("Tutorial Example\nresidual mag",
reference=gxgroup.REF_BOTTOM_CENTER,
location=(100, 10),
text_def=gxgroup.Text_def(height=3.5,
weight=gxgroup.FONT_WEIGHT_BOLD))
g.text("created by:" + gxc.gid,
location=(1, 1.5),
text_def=gxgroup.Text_def(height=1.2,
italics=True))
# add a map surround to the map
gmap.surround(outer_pen='kt500', inner_pen='kt100', gap=0.1)
# annotate the data view locations
gmap.annotate_data_xy(grid=gxmap.GRID_CROSSES)
gmap.annotate_data_ll(grid=gxmap.GRID_LINES,
grid_pen=gxgroup.Pen(line_color='b'),
text_def=gxgroup.Text_def(color='b',
height=0.15,
italics=True))
# scale bar
gmap.scale_bar(location=(1, 3, 1.5),
text_def=gxgroup.Text_def(height=0.15))
# display the map as an image
Image(gxmap.Map.open(map_file_name).image_file(pix_width=800))
Out[6]:
In [7]:
gxviewer.view_document(map_file_name, wait_for_close=False)